package com.vimtec.remote.client;

import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.net.InetSocketAddress;
import java.net.Socket;

public class RemoteIRobotHandler implements InvocationHandler
{
	
	private Socket sock = null;
	
	private OutputStream os = null;
	
	private ObjectOutputStream oos = null;
	
	public RemoteIRobotHandler(String host,int port) throws IOException
	{
		sock = new Socket();
		sock.connect(new InetSocketAddress(host,port));
		os = sock.getOutputStream();
		oos = new ObjectOutputStream(os);
		
	}

	public Object invoke(Object arg0, Method method, Object[] args)
			throws Throwable
	{
		oos.writeObject(method.getName());
		oos.writeObject(method.getParameterTypes());
		oos.writeObject(args);
		return null;
	}

}
